/*================================================================
*   Copyright (C) 2024 baichao All rights reserved.
*
*   文件名称：exec_family.c
*   创 建 者：baichao
*   创建日期：2024年04月05日
*   描    述：
*
================================================================*/

#include <unistd.h>

int main() {
  char *const ps_argv[] = {"ps", "-ax", NULL};
  char *const ps_envp[] = {"PATH=/bin:/usr/bin", "TERM=console", NULL};
  execl("/bin/ps", "ps", "-ax", NULL);
  /*带p的，可以使用环境变量PATH，无须写全路径*/
  execlp("ps", "ps", "-ax", NULL);
  /*带e的需要自己组拼环境变量*/
  execle("/bin/ps", "ps", "-ax", NULL, ps_envp);
  execv("/bin/ps", ps_argv);
  /*带p的，可以使用环境变量PATH，无须写全路径*/
  execvp("ps", ps_argv);
  /*带e的需要自己组拼环境变量*/
  execve("/bin/ps", ps_argv, ps_envp);
}
